package com.yhp.dao.impl;

import com.yhp.bean.Users;
import com.yhp.dao.DBUtils;
import com.yhp.dao.UserDao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class UserDaoImpl extends DBUtils implements UserDao {
    @Override
    public Users login(String uname, String pass) {
        Users users=null;
        try {
            //操作数据库
            String sql="select * from users where loginname=? and password=?";
            List params=new ArrayList();
            params.add(uname);
            params.add(pass);
            resultSet = query(sql, params);
            while(resultSet.next()){
                users=new Users();
                users.setLoginname(resultSet.getString("loginname"));
                users.setRealname(resultSet.getString("realname"));
                //id.password
            }
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        } finally {
            closeAll();
        }
        return users;
    }
}
